<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: drogon::CacheMap&lt; T1, T2 &gt; 模板类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacedrogon.html">drogon</a></li><li class="navelem"><a class="el" href="classdrogon_1_1CacheMap.html">CacheMap</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">类</a> &#124;
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="classdrogon_1_1CacheMap-members.html">所有成员列表</a>  </div>
  <div class="headertitle"><div class="title">drogon::CacheMap&lt; T1, T2 &gt; 模板类 参考</div></div>
</div><!--header-->
<div class="contents">

<p>Cache Map  
 <a href="classdrogon_1_1CacheMap.html#details">更多...</a></p>

<p><code>#include &lt;<a class="el" href="CacheMap_8h_source.html">CacheMap.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
类</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structdrogon_1_1CacheMap_1_1MapValue.html">MapValue</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:a4f16173f224c5de415192cf4c461363f" id="r_a4f16173f224c5de415192cf4c461363f"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#a4f16173f224c5de415192cf4c461363f">CacheMap</a> (trantor::EventLoop *loop, float tickInterval=<a class="el" href="CacheMap_8h.html#a75ffb1897670af90b6941ea94114a3b5">TICK_INTERVAL</a>, size_t wheelsNum=<a class="el" href="CacheMap_8h.html#a5bf4d6b54debb8fed97c0e7f4ac8e917">WHEELS_NUM</a>, size_t bucketsNumPerWheel=<a class="el" href="CacheMap_8h.html#afe38e091c33d2f4c6f379b6b4ba55bbf">BUCKET_NUM_PER_WHEEL</a>, std::function&lt; void(const T1 &amp;)&gt; fnOnInsert=nullptr, std::function&lt; void(const T1 &amp;)&gt; fnOnErase=nullptr)</td></tr>
<tr class="memdesc:a4f16173f224c5de415192cf4c461363f"><td class="mdescLeft">&#160;</td><td class="mdescRight">constructor  <br /></td></tr>
<tr class="separator:a4f16173f224c5de415192cf4c461363f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ade0249603273f1f24ca5c0787dae158a" id="r_ade0249603273f1f24ca5c0787dae158a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#ade0249603273f1f24ca5c0787dae158a">~CacheMap</a> ()</td></tr>
<tr class="separator:ade0249603273f1f24ca5c0787dae158a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6c41bed5e77af3d5faa97b79ee85efa8" id="r_a6c41bed5e77af3d5faa97b79ee85efa8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#a6c41bed5e77af3d5faa97b79ee85efa8">insert</a> (const T1 &amp;key, T2 &amp;&amp;value, size_t timeout=0, std::function&lt; void()&gt; timeoutCallback=std::function&lt; void()&gt;())</td></tr>
<tr class="memdesc:a6c41bed5e77af3d5faa97b79ee85efa8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Insert a key-value pair into the cache.  <br /></td></tr>
<tr class="separator:a6c41bed5e77af3d5faa97b79ee85efa8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a897a1047008e61da18344d98ec4b5483" id="r_a897a1047008e61da18344d98ec4b5483"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#a897a1047008e61da18344d98ec4b5483">insert</a> (const T1 &amp;key, const T2 &amp;value, size_t timeout=0, std::function&lt; void()&gt; timeoutCallback=std::function&lt; void()&gt;())</td></tr>
<tr class="memdesc:a897a1047008e61da18344d98ec4b5483"><td class="mdescLeft">&#160;</td><td class="mdescRight">Insert a key-value pair into the cache.  <br /></td></tr>
<tr class="separator:a897a1047008e61da18344d98ec4b5483"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa0a207d4d85ef264997a6181e7709fca" id="r_aa0a207d4d85ef264997a6181e7709fca"><td class="memItemLeft" align="right" valign="top">T2&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#aa0a207d4d85ef264997a6181e7709fca">operator[]</a> (const T1 &amp;key)</td></tr>
<tr class="memdesc:aa0a207d4d85ef264997a6181e7709fca"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the value of the keyword.  <br /></td></tr>
<tr class="separator:aa0a207d4d85ef264997a6181e7709fca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeff4880f58d38a470382ee7839ed1be0" id="r_aeff4880f58d38a470382ee7839ed1be0"><td class="memTemplParams" colspan="2">template&lt;typename Callable &gt; </td></tr>
<tr class="memitem:aeff4880f58d38a470382ee7839ed1be0"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#aeff4880f58d38a470382ee7839ed1be0">modify</a> (const T1 &amp;key, Callable &amp;&amp;handler, size_t timeout=0)</td></tr>
<tr class="memdesc:aeff4880f58d38a470382ee7839ed1be0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify or visit the data identified by the key parameter.  <br /></td></tr>
<tr class="separator:aeff4880f58d38a470382ee7839ed1be0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a038a26bb46512d4be847404fa9c2f74d" id="r_a038a26bb46512d4be847404fa9c2f74d"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#a038a26bb46512d4be847404fa9c2f74d">find</a> (const T1 &amp;key)</td></tr>
<tr class="memdesc:a038a26bb46512d4be847404fa9c2f74d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check if the value of the keyword exists  <br /></td></tr>
<tr class="separator:a038a26bb46512d4be847404fa9c2f74d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0f72578a2303df1c615668c830a1126e" id="r_a0f72578a2303df1c615668c830a1126e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#a0f72578a2303df1c615668c830a1126e">findAndFetch</a> (const T1 &amp;key, T2 &amp;value)</td></tr>
<tr class="memdesc:a0f72578a2303df1c615668c830a1126e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Atomically find and get the value of a keyword  <br /></td></tr>
<tr class="separator:a0f72578a2303df1c615668c830a1126e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6b9542f834ba3d95de8a17482cde1911" id="r_a6b9542f834ba3d95de8a17482cde1911"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#a6b9542f834ba3d95de8a17482cde1911">erase</a> (const T1 &amp;key)</td></tr>
<tr class="memdesc:a6b9542f834ba3d95de8a17482cde1911"><td class="mdescLeft">&#160;</td><td class="mdescRight">Erase the value of the keyword.  <br /></td></tr>
<tr class="separator:a6b9542f834ba3d95de8a17482cde1911"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af9f0161d95e254de29d1f4fdc857084c" id="r_af9f0161d95e254de29d1f4fdc857084c"><td class="memItemLeft" align="right" valign="top">trantor::EventLoop *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#af9f0161d95e254de29d1f4fdc857084c">getLoop</a> ()</td></tr>
<tr class="memdesc:af9f0161d95e254de29d1f4fdc857084c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the event loop object  <br /></td></tr>
<tr class="separator:af9f0161d95e254de29d1f4fdc857084c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3df0af3b66a38495ebf1ea4086a81e09" id="r_a3df0af3b66a38495ebf1ea4086a81e09"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#a3df0af3b66a38495ebf1ea4086a81e09">runAfter</a> (size_t delay, std::function&lt; void()&gt; &amp;&amp;task)</td></tr>
<tr class="memdesc:a3df0af3b66a38495ebf1ea4086a81e09"><td class="mdescLeft">&#160;</td><td class="mdescRight">run the task function after a period of time.  <br /></td></tr>
<tr class="separator:a3df0af3b66a38495ebf1ea4086a81e09"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afe43117698d76c1522e51b8f439d51f8" id="r_afe43117698d76c1522e51b8f439d51f8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1CacheMap.html#afe43117698d76c1522e51b8f439d51f8">runAfter</a> (size_t delay, const std::function&lt; void()&gt; &amp;task)</td></tr>
<tr class="separator:afe43117698d76c1522e51b8f439d51f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><div class="compoundTemplParams">template&lt;typename T1, typename T2&gt;<br />
class drogon::CacheMap&lt; T1, T2 &gt;</div><p>Cache Map </p>
<dl class="tparams"><dt>模板参数</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T1</td><td>The keyword type. </td></tr>
    <tr><td class="paramname">T2</td><td>The value type. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>注解</dt><dd>Four wheels with 200 buckets per wheel means the cache map can work with a timeout up to 200^4 seconds (about 50 years). </dd></dl>
</div><h2 class="groupheader">构造及析构函数说明</h2>
<a id="a4f16173f224c5de415192cf4c461363f" name="a4f16173f224c5de415192cf4c461363f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4f16173f224c5de415192cf4c461363f">&#9670;&#160;</a></span>CacheMap()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::CacheMap </td>
          <td>(</td>
          <td class="paramtype">trantor::EventLoop *&#160;</td>
          <td class="paramname"><em>loop</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>tickInterval</em> = <code><a class="el" href="CacheMap_8h.html#a75ffb1897670af90b6941ea94114a3b5">TICK_INTERVAL</a></code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>wheelsNum</em> = <code><a class="el" href="CacheMap_8h.html#a5bf4d6b54debb8fed97c0e7f4ac8e917">WHEELS_NUM</a></code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>bucketsNumPerWheel</em> = <code><a class="el" href="CacheMap_8h.html#afe38e091c33d2f4c6f379b6b4ba55bbf">BUCKET_NUM_PER_WHEEL</a></code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::function&lt; void(const T1 &amp;)&gt;&#160;</td>
          <td class="paramname"><em>fnOnInsert</em> = <code>nullptr</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::function&lt; void(const T1 &amp;)&gt;&#160;</td>
          <td class="paramname"><em>fnOnErase</em> = <code>nullptr</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>constructor </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">loop</td><td>eventloop pointer </td></tr>
    <tr><td class="paramname">tickInterval</td><td>second </td></tr>
    <tr><td class="paramname">wheelsNum</td><td>number of wheels </td></tr>
    <tr><td class="paramname">bucketsNumPerWheel</td><td>buckets number per wheel </td></tr>
    <tr><td class="paramname">fnOnInsert</td><td>function to execute on insertion </td></tr>
    <tr><td class="paramname">fnOnErase</td><td>function to execute on erase</td></tr>
  </table>
  </dd>
</dl>
<p>The max delay of the <a class="el" href="classdrogon_1_1CacheMap.html" title="Cache Map">CacheMap</a> is about tickInterval*(bucketsNumPerWheel^wheelsNum) seconds. </p>

</div>
</div>
<a id="ade0249603273f1f24ca5c0787dae158a" name="ade0249603273f1f24ca5c0787dae158a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ade0249603273f1f24ca5c0787dae158a">&#9670;&#160;</a></span>~CacheMap()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::~<a class="el" href="classdrogon_1_1CacheMap.html">CacheMap</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">成员函数说明</h2>
<a id="a6b9542f834ba3d95de8a17482cde1911" name="a6b9542f834ba3d95de8a17482cde1911"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6b9542f834ba3d95de8a17482cde1911">&#9670;&#160;</a></span>erase()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::erase </td>
          <td>(</td>
          <td class="paramtype">const T1 &amp;&#160;</td>
          <td class="paramname"><em>key</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Erase the value of the keyword. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">key</td><td>the keyword. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>注解</dt><dd>This function does not cause the timeout callback to be executed. </dd></dl>

</div>
</div>
<a id="a038a26bb46512d4be847404fa9c2f74d" name="a038a26bb46512d4be847404fa9c2f74d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a038a26bb46512d4be847404fa9c2f74d">&#9670;&#160;</a></span>find()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::find </td>
          <td>(</td>
          <td class="paramtype">const T1 &amp;&#160;</td>
          <td class="paramname"><em>key</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Check if the value of the keyword exists </p>

</div>
</div>
<a id="a0f72578a2303df1c615668c830a1126e" name="a0f72578a2303df1c615668c830a1126e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0f72578a2303df1c615668c830a1126e">&#9670;&#160;</a></span>findAndFetch()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::findAndFetch </td>
          <td>(</td>
          <td class="paramtype">const T1 &amp;&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">T2 &amp;&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Atomically find and get the value of a keyword </p>
<p>Return true when the value is found, and the value is assigned to the value argument. </p>

</div>
</div>
<a id="af9f0161d95e254de29d1f4fdc857084c" name="af9f0161d95e254de29d1f4fdc857084c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af9f0161d95e254de29d1f4fdc857084c">&#9670;&#160;</a></span>getLoop()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">trantor::EventLoop * <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::getLoop </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get the event loop object </p>
<dl class="section return"><dt>返回</dt><dd>trantor::EventLoop* </dd></dl>

</div>
</div>
<a id="a897a1047008e61da18344d98ec4b5483" name="a897a1047008e61da18344d98ec4b5483"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a897a1047008e61da18344d98ec4b5483">&#9670;&#160;</a></span>insert() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::insert </td>
          <td>(</td>
          <td class="paramtype">const T1 &amp;&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const T2 &amp;&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>timeout</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::function&lt; void()&gt;&#160;</td>
          <td class="paramname"><em>timeoutCallback</em> = <code>std::function&lt;void()&gt;()</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Insert a key-value pair into the cache. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">key</td><td>The key </td></tr>
    <tr><td class="paramname">value</td><td>The value </td></tr>
    <tr><td class="paramname">timeout</td><td>The timeout in seconds, if timeout &gt; 0, the value will be erased within the 'timeout' seconds after the last access. If the timeout is zero, the value exists until being removed explicitly. </td></tr>
    <tr><td class="paramname">timeoutCallback</td><td>is called when the timeout expires. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a6c41bed5e77af3d5faa97b79ee85efa8" name="a6c41bed5e77af3d5faa97b79ee85efa8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6c41bed5e77af3d5faa97b79ee85efa8">&#9670;&#160;</a></span>insert() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::insert </td>
          <td>(</td>
          <td class="paramtype">const T1 &amp;&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">T2 &amp;&amp;&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>timeout</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::function&lt; void()&gt;&#160;</td>
          <td class="paramname"><em>timeoutCallback</em> = <code>std::function&lt;void()&gt;()</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Insert a key-value pair into the cache. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">key</td><td>The key </td></tr>
    <tr><td class="paramname">value</td><td>The value </td></tr>
    <tr><td class="paramname">timeout</td><td>The timeout in seconds, if timeout &gt; 0, the value will be erased within the 'timeout' seconds after the last access. If the timeout is zero, the value exists until being removed explicitly. </td></tr>
    <tr><td class="paramname">timeoutCallback</td><td>is called when the timeout expires. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aeff4880f58d38a470382ee7839ed1be0" name="aeff4880f58d38a470382ee7839ed1be0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeff4880f58d38a470382ee7839ed1be0">&#9670;&#160;</a></span>modify()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<div class="memtemplate">
template&lt;typename Callable &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::modify </td>
          <td>(</td>
          <td class="paramtype">const T1 &amp;&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Callable &amp;&amp;&#160;</td>
          <td class="paramname"><em>handler</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>timeout</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Modify or visit the data identified by the key parameter. </p>
<dl class="tparams"><dt>模板参数</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">Callable</td><td>the type of the handler. </td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">key</td><td></td></tr>
    <tr><td class="paramname">handler</td><td>A callable that can modify or visit the data. The signature of the handler should be equivalent to 'void(T2&amp;)' or 'void(const T2&amp;)' </td></tr>
    <tr><td class="paramname">timeout</td><td>In seconds.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>注解</dt><dd>This function is multiple-thread safe. if the data identified by the key doesn't exist, a new one is created and passed to the handler and stored in the cache with the timeout parameter. The changing of the data is protected by the mutex of the cache. </dd></dl>

</div>
</div>
<a id="aa0a207d4d85ef264997a6181e7709fca" name="aa0a207d4d85ef264997a6181e7709fca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa0a207d4d85ef264997a6181e7709fca">&#9670;&#160;</a></span>operator[]()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T2 <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::operator[] </td>
          <td>(</td>
          <td class="paramtype">const T1 &amp;&#160;</td>
          <td class="paramname"><em>key</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the value of the keyword. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">key</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>T2 </dd></dl>
<dl class="section note"><dt>注解</dt><dd>This function returns a copy of the data in the cache. If the data is not found, a default T2 type value is returned and nothing is inserted into the cache. </dd></dl>

</div>
</div>
<a id="afe43117698d76c1522e51b8f439d51f8" name="afe43117698d76c1522e51b8f439d51f8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afe43117698d76c1522e51b8f439d51f8">&#9670;&#160;</a></span>runAfter() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::runAfter </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>delay</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const std::function&lt; void()&gt; &amp;&#160;</td>
          <td class="paramname"><em>task</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<a id="a3df0af3b66a38495ebf1ea4086a81e09" name="a3df0af3b66a38495ebf1ea4086a81e09"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3df0af3b66a38495ebf1ea4086a81e09">&#9670;&#160;</a></span>runAfter() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T1 , typename T2 &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1CacheMap.html">drogon::CacheMap</a>&lt; T1, T2 &gt;::runAfter </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>delay</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::function&lt; void()&gt; &amp;&amp;&#160;</td>
          <td class="paramname"><em>task</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>run the task function after a period of time. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">delay</td><td>in seconds </td></tr>
    <tr><td class="paramname">task</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>注解</dt><dd>This timer is a low-precision timer whose accuracy depends on the tickInterval parameter of the cache. The advantage of the timer is its low cost. </dd></dl>

</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li><a class="el" href="CacheMap_8h_source.html">CacheMap.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
